/*
 * UDPDebug.c
 *
 * Created: 2011-11-25 22:14:58
 *  Author: krzychu
 */ 

#include "UDPDebug.h"
#include "enc28j60.h"
#include "ethernet.h"
#include "main.h"
#include <stdio.h>

extern	byte	out_buffer[MTU_SIZE];
extern	Device 		dev;

void	UDP_DEBUG_Send( byte *data )
{
	UINT16 len;
	byte		*out;
	ETH_Header	*out_eth;
	IP_Header	*out_ip;
	UDP_Header	*out_udp;
	
	out		= &out_buffer[UDP_DATA];
	out_eth = (ETH_Header *)	&out_buffer[ETH_OFFSET];
	out_ip	= (IP_Header *)		&out_buffer[IP_OFFSET];
	out_udp	= (UDP_Header *)	&out_buffer[UDP_OFFSET];
	
	len = sprintf_P(&out_buffer[UDP_DATA], data)
	
	Make_UDP_Header( &dev.mac, &dev.ip, UDP_DEBUG_PORT, len );
	
	ENC28J60_SendPacket(len, &out_buffer);
}